package com.nfIt.servlet;

import com.nfIt.dao.StaffsDao;
import com.nfIt.dao.impl.StaffsDaoImpl;
import com.nfIt.pojo.staffs;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * ClossName:InsertStaff
 * Pakage:com.nfIt.servlet
 * Description
 *
 * @Author L
 * @Create 2024/3/12 14:51
 * @Version 2023.1.3
 */
@WebServlet("/InsertStaff")
public class InsertStaff extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        StaffsDao staffsDao = new StaffsDaoImpl();
        staffs staffs = new staffs();
        staffs.setName("liao");
        staffs.setAge(18);
        staffs.setPhone("13418405596");
        staffs.setPos("xxxxccccvvvv");

        LocalDateTime localDateTime = LocalDateTime.now();

        staffs.setAdd_time(localDateTime);
        staffs.setUpdate_time(localDateTime);

        int rows = staffsDao.insertStaffs(staffs);
        System.out.println(rows);

        PrintWriter out = resp.getWriter();
        out.print(rows);
        out.flush();
        out.close();
    }
}
